﻿using GameServer.Virtual_Objects.User;
using GameServer.Networking.Packets;
using System;
using GameServer;

namespace GameServer.Networking.Handlers
{
    class HANDLE_WELCOME_PACKET : PacketHandler
    {
        public override void Handle(virtualUser User)
        {
            int GameVersion = int.Parse(getBlock(1));
            if (GameVersion != Config.ClientVersion)
            {
                User.send(new PACKET_LOGIN(PACKET_LOGIN.ErrorCodes.ClientVersionMissmatch));
            }
            User.HWID = getBlock(2);
            int HWID = DB.runRead("SELECT * FROM users_hwid WHERE hwid='" + User.HWID + "'", null);
            if (HWID > 0)
            {
                User.send(new PACKET_CHAT(User, PACKET_CHAT.ChatType.Notice1, " You're got disconnected because your HWID it's banned.", 100, "Server"));
                User.disconnect();
            }
            User.send(new PACKET_LOGIN());
        }
    }
}
